package com.five.matebook.activity.config;

import android.content.Context;

import com.five.matebook.utils.SharedPreferencesUtil;
import com.google.gson.Gson;

public class StroageConfig {
    public static void save(Context context) {
        synchronized (StroageConfig.class) {
            if (sInstance != null) {
                Gson gson = new Gson();
                SharedPreferencesUtil.saveJsonData(context, gson.toJson(sInstance));
            }
        }
    }

    private static volatile ConfigDataBean sInstance = null;
    public static ConfigDataBean get(Context context) {
        if (sInstance == null) {
            synchronized (StroageConfig.class) {
                if (sInstance == null) {
                    Gson gson = new Gson();
                    ConfigDataBean ret = gson.fromJson(SharedPreferencesUtil.getJsonData(context), ConfigDataBean.class);
                    sInstance = ret != null ? ret : new ConfigDataBean();
                }
            }
        }
        return sInstance;
    }
}
